extends Node2D
@onready var 回合tree = %"回合Tree"

var 回合tree_root
var 回合行棋集:Array=[]
func _ready():
	初始化回合信息()
	
func 初始化回合信息():
	回合tree.clear()
	回合tree.set_column_title(0, "回合")
	回合tree.set_column_title(1, "行棋")
	回合tree.set_column_title_alignment(0, HORIZONTAL_ALIGNMENT_LEFT)
	回合tree.set_column_title_alignment(1, HORIZONTAL_ALIGNMENT_LEFT)
	回合tree.set_column_custom_minimum_width(0,100)
	回合tree.set_column_custom_minimum_width(1,200)
	回合tree_root = 回合tree.create_item()
	
func 添加行棋信息(行棋信息:Dictionary):
	var 回合行棋 = 回合tree.create_item(回合tree_root)
	回合行棋.set_text(0, 行棋信息.回合)
	回合行棋.set_text(1, 行棋信息.行棋)
	回合tree.scroll_to_item(回合行棋)
	回合行棋集.append(回合行棋)

func 悔棋():
	var item=回合行棋集.pop_back()
	item.free()
